//
//  RegistSecondVC.m
//  YangWifi
//
//  Created by zuoxueliangduyuanzhuo on 2017/11/13.
//  Copyright © 2017年 zuoxueliangduyuanzhuo. All rights reserved.
//

#import "RegistSecondVC.h"
#import "NSString+Ext.h"
#import "Regex.h"
@interface RegistSecondVC ()

@property (nonatomic ,weak) IBOutlet UITextField *nickTf;

@property (nonatomic ,weak) IBOutlet UITextField *pwdTf;

@property (nonatomic ,weak) IBOutlet UIButton *registBtn;

@end

@implementation RegistSecondVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = self.pwdType == ForgotPwdType?@"忘记密码":@"注册第二步";
    if (self.pwdType == ForgotPwdType) {
    
        [self.registBtn setTitle:@"确认修改" forState:UIControlStateNormal];
        [self.registBtn setTitle:@"确认修改" forState:UIControlStateHighlighted];
        self.nickTf.placeholder = @"设置新密码";
        self.pwdTf.placeholder = @"重置新密码";
        self.nickTf.keyboardType = UIKeyboardTypeEmailAddress;
        self.pwdTf.keyboardType = UIKeyboardTypeEmailAddress;
        self.nickTf.secureTextEntry = YES;
        self.pwdTf.secureTextEntry = YES;
    
    }else{
        
        [self.registBtn setTitle:@"完成注册" forState:UIControlStateNormal];
        [self.registBtn setTitle:@"完成注册" forState:UIControlStateHighlighted];
        self.nickTf.placeholder = @"设置昵称";
        self.pwdTf.placeholder = @"设置密码";
        self.nickTf.keyboardType = UIKeyboardTypeDefault;
        self.pwdTf.keyboardType = UIKeyboardTypeEmailAddress;
        self.nickTf.secureTextEntry = NO;
        self.pwdTf.secureTextEntry = YES;

    }


}

- (IBAction)registAction:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (BOOL)regexRegistInfo
{
    if ([[NSString deleteForeAndAftSpace:self.nickTf.text] length] == 0) {
        
        if (self.pwdType == ForgotPwdType) {
            [self.view makeToast:@"请输入新密码"];

        }else{
            [self.view makeToast:@"请输入昵称"];

        }
        return NO;
        
    }
    
    if ([[NSString deleteForeAndAftSpace:self.pwdTf.text] length] == 0){
        
        if (self.pwdType == ForgotPwdType) {
            
            [self.view makeToast:@"请重复输入新密码"];
            
        }else{
            
            [self.view makeToast:@"请输入密码"];
            
        }
        return NO;
    }
    
    if (self.pwdType == ForgotPwdType) {
        
        if ([self.pwdTf.text isEqualToString:self.nickTf.text]) {

            [self.view makeToast:@"请确保两次输入的密码一致"];

        }
    }
    
    return YES;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
